package com.yunyan.util.predict;

// 预测概率计算
public class AdmissionRatio {


    public static double calculateF2(int a, int b, int c, int x, double p){
        double m=0.8, n=0.8;
       if (x <= c) {
           return 0.999;
       }
       if (x > b) {
           return 0.001;
       }

       if (x > c && x <= a) {
           return ((a-x)/(a-c))*(1-m)+m;
       }

        if (x > a && x <= b) {
           return  (n* (b-x) / (b-a) + p*(1-n) ) * m;
        }
        return 0;
    }

    public static double calculateF1(int predictScore, int realScore){
        int x = 0;
        if (predictScore > 650) {
            x = 2;
        } else {
            x = 1;
        }
        int diff = realScore - predictScore;
        if (x == 2) {
            double ratio = diff / x;
            if (ratio > 2.6) {
                return 0.99865;
            }
            if (ratio > 2.1) {
                return 0.9938;
            }
            if (ratio > 1.6) {
                return 0.9772;
            }
            if (ratio > 1.1) {
                return 0.9332;
            }
            if (ratio > 0.6) {
                return 0.8413;
            }
            if (ratio > 0.1) {
                return 0.6915;
            }
            if (ratio == 0) {
                return 0.5;
            }
            if (ratio < -2.6) {
                return 0.00135;
            }
            if (ratio < -2.1) {
                return 0.0062;
            }
            if (ratio < -1.6) {
                return 0.0228;
            }
            if (ratio < -1.1) {
                return 0.0668;
            }
            if (ratio < -0.6) {
                return 0.1587;
            }
            if (ratio < -0.1) {
                return 0.3085;
            }
        } else {
            if (diff >= 3) {
                return 0.99865;
            }
            if (diff == 2) {
                return 0.9772;
            }
            if (diff == 1) {
                return 0.8413;
            }
            if (diff == 0) {
                return 0.5;
            }
            if (diff <= -3) {
                return 0.00135;
            }
            if (diff == -2) {
                return 0.0228;
            }
            if (diff == -1) {
                return 0.1587;
            }
        }
        return 0;

    }

}
